﻿#define _CRT_SECURE_NO_WARNINGS 1

#include "SList.h"

void TestSList1()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);

	SLTPrint(plist);
}

void TestSList2()
{
	SLTNode* plist = NULL;
	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);

	SLTPrint(plist);
}

void TestSList3()
{
	SLTNode* plist = NULL;
	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);

	SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);


	SLTPopBack(&plist);
	SLTPrint(plist);


	SLTPopBack(&plist);
	SLTPrint(plist);

	SLTPopBack(&plist);

	SLTPrint(plist);
}

void TestSList4()
{
	SLTNode* plist = NULL;
	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);

	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);

	SLTPopFront(&plist);
	SLTPrint(plist);

}

void TestSList5()
{
	SLTNode* plist = NULL;
	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);

	SLTPrint(plist);

	//值为2的那个节点 * 2
	SLTNode* ret = SLTFind(plist, 1);
	ret->data *= 2;

	ret = SLTFind(plist, 2);
	ret->data *= 2;

	ret = SLTFind(plist, 3);
	ret->data *= 2;

	SLTPrint(plist);

}

void TestSList6()
{
	SLTNode* plist = NULL;
	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);

	SLTPrint(plist);

	//找到值为1的那个节点，并在该节点的位置前面插入 20 
	SLTNode* ret = SLTFind(plist, 1);
	SLTInsert(&plist, ret, 20);

	SLTPrint(plist);
}

void TestSList7()
{
	SLTNode* plist = NULL;
	SLTPushFront(&plist, 1);
	SLTPushFront(&plist, 2);
	SLTPushFront(&plist, 3);

	SLTPrint(plist);

	//找到值为1的那个节点，并删除
	SLTNode* ret = SLTFind(plist, 1);
	SLTErase(&plist,ret);
	ret = NULL;

	SLTPrint(plist);
}

int main()
{
	//调用test函数
	TestSList7();

	return 0;
}